window.path = 'http://139.199.75.210:8081'
$(function () {
  var validate = {
    //头部iframe 添加地址栏参数用于配置 菜单选中项
    heardIframe: function () {
      $('#heardIframe').attr('src', '../../dist/views/common/head.html' + window.location.search)
    },
    // 悬浮
    rightBox: function () {

      // 配置信息
      rightJson = [
        {
          imgUrl: '../../dist/images/qq.png',
          classname: 'qq tc',
          target: '_blank',
          txt: '在线客服',
          href: 'http://wpa.qq.com/msgrd?v=3&uin=2692703704&site=qq&menu=yes'
        },
        {
          txt: '微信咨询',
          imgUrl: '../../dist/images/wx.png',
          classname: 'wxEWM tc mt5',
          child: '<img src="../../dist/images/wxEWM.png" class="none ewm pa" alt="">',
          target: '',
          href: ''
        },
        {
          txt: '顶部',
          imgUrl: '../../dist/images/top.png',
          classname: 'top tc mt5 none',
          target: '',
          href: ''
        },]
      var top = (74 * 3 + 5 * 2) / 2
      var style = 'margin-top:-' + top + 'px;'
      var rightBox = '<ul class="rightBox" style=' + style + '>';
      for (var i = 0; i < rightJson.length; i++) {
        rightBox += '	<li class="' + rightJson[i].classname + ' rightBox' + i + '">';
        rightBox += '	<a target="' + rightJson[i].target + '" href="' + (rightJson[i].href || 'javascript:;') + '" class="color1">';
        rightBox += '	<img src="' + rightJson[i].imgUrl + '">';
        rightBox += '<p class="tc">' + rightJson[i].txt + '</p>';
        if (rightJson[i].child) {
          rightBox += rightJson[i].child
        }
        rightBox += '</a>';
        rightBox += '</li>';
      }
      rightBox += '</ul>';
      $('.body').append(rightBox)
      $('.body').on('click', '.rightBox2', function () {
        validate.topfun()
      })
      var returnTop = $('.rightBox2');
      $(window).scroll(function () {
        if ($(this).scrollTop() > $(window).height()) {
          returnTop.fadeIn();
        } else {
          returnTop.fadeOut();
        }
      });
    },
    topfun: function (eachHeight) {
      var sc_top = $(document).scrollTop();
      var ini_h = 0.1;
      timer = setInterval(function () {
        if (sc_top - ini_h <= 0) {
          $(window).scrollTop(0);
          timer && clearInterval(timer);
        } else {
          sc_top = sc_top - ini_h;
          $(window).scrollTop(sc_top);
        }
        ini_h += 5;		//数字越大走越快  
      }, 10);
    }
  }
  validate.heardIframe()
  validate.rightBox()
})